home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97b.txt / 000059_icon-group-sender _Thu Sep 4 15:02:46 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Thu, 4 Sep 1997 15:02:45 -0500 (EST)
  3. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  4.     id AA25059; Thu, 4 Sep 1997 13:02:45 -0700
  5. To: icon-group
  6. Date: 04 Sep 1997 10:57:37 -0400
  7. From: davidf@mks.com (David J. Fiander)
  8. Message-Id: <uoh69f7oe.fsf_-_@davidf-nt.mks.com>
  9. Organization: Mortice Kern Systems Inc.
  10. Sender: icon-group-request
  11. References: <comp.lang.dylan.199708151441.PAA09067@gairsay.aiai.ed.ac.uk>
  12. Subject: n-ary comparison operators (was Re: Better Dylan syntax?)
  13. Errors-To: icon-group-errors
  14. Status: RO
  15.  
  16. Gareth McCaughan <gjm11@dpmms.cam.ac.uk> writes:
  17. > Erik Naggum wrote:
  18. > > hm.  in a < b `<' is a binary operator, while it is ternary in a < b < c,
  19. > > and n-ary in a < b < ... < z.  although I know of no language that has
  20. > > anything but binary infix operators, I get the impression from the above
  21. > > that you do.
  22. > Yes. BCPL does it. "a < b <= c ~= d" means "a<b and b<=c and c/=d".
  23. > I don't know of any other languages with the same feature, but I'd
  24. > be surprised if BCPL were the only one.
  25.  
  26. Icon supports n-ary infix operators:
  27.  
  28.     a < b < c ~= d
  29.  
  30. produces the same result as BCPL.  This works because
  31. comparisions are left associative, and successful comparisons
  32. return the right operand.  That is, the above expression is
  33. equivalent to
  34.  
  35.     (((a < b) < c) ~= d)
  36.  
  37. and if a < b, then b is compared to c, and so on.  If a >= b,
  38. then the expression fails, and none of the rest of it is evaluated.
  39.